import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
import 'package:village_android/component/icon_tile.dart';
import 'package:village_android/component/jd_button.dart';
import 'package:village_android/model/order_model.dart';
import 'package:village_android/model/wx_pay_model.dart';
import 'package:village_android/pages/health/health_submit_detail_page.dart';
import 'package:village_android/utils/common_utils.dart';
import 'package:village_android/utils/http_utlis.dart';

class OrderDetailPage extends StatefulWidget {
  OrderModel orderModel;

  OrderDetailPage({this.orderModel});

  @override
  _OrderDetailPageState createState() => _OrderDetailPageState();
}

class _OrderDetailPageState extends State<OrderDetailPage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('订单详情'),
      ),
      body: localWidget(),
      bottomNavigationBar: initBottom(),
    );
  }

  Widget localWidget() {
    return SingleChildScrollView(
      padding: EdgeInsets.all(20.0),
      child: Column(children: <Widget>[
        initTitle(),
        initOrderId(),
        initTargetId(),
        initType(),
        initUserName(),
        initRemark(),
      ]),
    );
  }

  TextFormField initUserName() {
    return TextFormField(
      enabled: false,
      initialValue: widget.orderModel.name,
      decoration: InputDecoration(labelText: '姓名'),
    );
  }

  TextFormField initOrderId() {
    return TextFormField(
      enabled: false,
      initialValue: widget.orderModel.orderId,
      decoration: InputDecoration(labelText: '订单ID'),
    );
  }
  TextFormField initTargetId() {
    return TextFormField(
      enabled: false,
      initialValue: widget.orderModel.targetId.toString(),
      decoration: InputDecoration(labelText: '卫生费申请ID'),
    );
  }

  TextFormField initTitle() {
    return TextFormField(
      enabled: false,
      initialValue: widget.orderModel.title,
      decoration: InputDecoration(labelText: '标题'),
    );
  }

  TextFormField initAmount() {
    return TextFormField(
      enabled: false,
      initialValue: widget.orderModel.amount,
      decoration: InputDecoration(labelText: '金额'),
    );
  }

  TextFormField initRemark() {
    return TextFormField(
      enabled: false,
      initialValue: widget.orderModel.remark,
      decoration: InputDecoration(labelText: '备注'),
    );
  }

  TextFormField initType() {
    return TextFormField(
      enabled: false,
      initialValue: "卫生费",
      decoration: InputDecoration(labelText: '类型'),
    );
  }

  Widget initBottom() {
    return BottomAppBar(
        child: Row(
      children: <Widget>[
        Expanded(
            child: JdButton(
          callBack: () {
            toSubmitDetail();
          },
          text: "查看卫生费申请详情",
          color: Colors.red,
        ))
      ],
    ));
  }

  Future toSubmitDetail() async {

    var page = new HealthSubmitDetailPage(
      healthPaySubmitId: widget.orderModel.targetId,
    );
    final result = await Navigator.push(
        context, new MaterialPageRoute(builder: (context) => page));
    if (result != null) {

    }
  }


}
